{% extends "to_do_list/base.html" %}

{% block 网页名字 %}我的待办事项{% endblock 网页名字 %}


{% block 主体内容 %}
<main role="main" class="container">

    {% if 信息 == "添加成功" %}
        <div class="alert alert-success" role="alert"><strong>添加成功！</strong></div>
    {% elif 信息 == None %}
        <div class="alert alert-warning" role="alert">请输入添加内容</div>
    {% else %}
    {% endif %}

    <table class="table table-hover">
        <thead class="thead-light">
        <tr>
            <th scope="col">序号</th>
            <th scope="col">待办事项</th>
            <th scope="col">编辑</th>
            <th scope="col">划掉</th>
            <th scope="col">删除</th>
        </tr>
        </thead>
        <tbody class="no-underline">
            {% for every_work in 清单 %}
            {% if every_work.status == "finished" %}
                <tr class="table-dark">
                    <th class="text-dark" scope="row">{{ forloop.counter }}</th>
                    <td class="text-dark" id="line-through">{{ every_work.work }}</td>
                    <td>
                        <form action="#">
                            <button class="btn btn-dark btn-sm-0">编辑</button>
                        </form>
                    </td>
                    <td>
                        <form method="POST" action="{% url 'to_do_list:是否完成' forloop.counter %}">
                            {% csrf_token %}
                            <input name="状态" type="hidden" value=False>
                            <button class="btn btn-primary btn-sm-0"  type="submit">撤销</button>
                        </form>
                    </td>
                    <td>
                        <form method="POST" action="{% url 'to_do_list:删除' forloop.counter %}">
                            {% csrf_token %}
                            <button class="btn btn-danger btn-sm-0"  type="submit">删除</button>
                        </form>
                    </td>
                </tr>
            {% else %}
                <tr>
                    <th scope="row">{{ forloop.counter }}</th>
                    <td>{{ every_work.work }}</td>
                    <td>
                        <form method="GET" action="{% url 'to_do_list:添加事项' forloop.counter %}">
                            {% csrf_token %}
                            <button class="btn btn-success btn-sm-0"  type="submit">编辑</button>
                        </form>
                    </td>
                    <td>
                        <form method="POST" action="{% url 'to_do_list:是否完成' forloop.counter %}">
                            {% csrf_token %}
                            <input name="状态" type="hidden" value="finished">
                            <button class="btn btn-primary btn-sm-0"  type="submit">完成</button>
                        </form>
                    </td>
                    <td>
                        <form method="POST" action="{% url 'to_do_list:删除' forloop.counter %}">
                            {% csrf_token %}
                            <button class="btn btn-danger btn-sm-0"  type="submit">删除</button>
                        </form>
                    </td>
                </tr>
            {% endif %}
            {% endfor %}


        </tbody>
    </table>
</main>

{% endblock 主体内容 %}
